local dangyan = fk.CreateSkill {
  name = "3s__dangyan",
}

Fk:loadTranslationTable{
  ["3s__dangyan"] = "荡言",
  [":3s__dangyan"] = "一名角色的出牌阶段开始时，其可令你你交换“臬义”中的“有”和“无”，然后你视为使用【无中生有】，此阶段结束时，若你未发动过“看破”或“慷忾”，其可对你造成1点伤害。",
  ["#3s__dangyan-ask"] = "荡言：你可以令 %dest 视为使用【无中生有】",
  ["#3s__dangyan-damage"] = "荡言：你可以对 %dest 造成1点伤害。",
}

dangyan:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target.phase == Player.Play and player:hasSkill(dangyan.name) 
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(target, {skill_name = dangyan.name, prompt = "#3s__dangyan-ask::" .. player.id})
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("nieyi_fix") == 0 then
      room:addPlayerMark(player, "nieyi_fix")
    else
      room:setPlayerMark(player, "nieyi_fix", 0)
    end
    room:useVirtualCard("lvshi__ex_nihilo", nil, player, player, dangyan.name)
  end,
})

dangyan:addEffect(fk.EventPhaseEnd, {
  anim_type = "negative",
  --is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target.phase == Player.Play and player:hasSkill(dangyan.name)
    and player:usedSkillTimes(dangyan.name, Player.HistoryPhase) > 0
    and player:usedSkillTimes("3s__kanpo", Player.HistoryPhase) == 0
    and player:usedSkillTimes("3s__kangkai", Player.HistoryPhase) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(target, {skill_name = dangyan.name, prompt = "#3s__dangyan-damage::" .. player.id})
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:damage({
      from = target,
      to = player,
      damage = 1,
      skillName = dangyan.name,
    })
  end,
})

return dangyan